<template>
  <el-select @change="changeEvent" :value='value' clearable :placeholder="placeholder">
    <el-option v-for="item in caseTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  </el-select>
</template>

<script>
export default {
  name: "CaseTypeSelect",
  props: {
      placeholder: String
  },
  data() {
    return {
        value: '',
        caseTypeList: []
    };
  },
  created() {
      this.getCaseTypeList();
  },
  methods: {
    clear() {
      this.value = '';
    },
    setValue(val) {
      this.value = val;
    },
    getCaseTypeList() {
      this.$store.dispatch('GET_CASE_TYPE_LIST').then(res => {
        if(res.data.retCode == 0) {
          this.caseTypeList = res.data.data;
        }
      }).catch(err => {
        console.error('获取分类列表：：', err)
      });
    },
    changeEvent(caseType) {
        console.log('caseType:::', caseType);
        this.value = caseType;
        this.$emit('getCaseType', caseType)
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
